import { createApp } from 'vue'
import pinia from './store'
import App from './App.vue'
import router, { startPromise } from './router'
import useElementPlus from './element-plus'
import IconSvg from './icons'
import useComponent from "@/components"
import './assets/scss/main.scss'
import './assets/scss/each.scss'
import "@/utils/flexible";
import useApp from './store/app'
import { getToken } from './utils'
const app = createApp(App)

// app.use(ElementPlus, { locale: zhCn })
const appStore = useApp(pinia)
useElementPlus(app)
useComponent(app)
app.use(IconSvg)
app.use(pinia);

// 处理动态路由刷新页面白屏问题
(async function () {
    if (getToken()) {
        await appStore.initMenus()
        await startPromise()
        setTimeout(() => { app.use(router).mount('#app') }, 0)
    } else {
        app.use(router).mount('#app')
    }
})()



